home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 8_6.lha / 8_6 / 8_6_stream.h < prev    next >
C/C++ Source or Header  |  1993-08-08  |  1KB  |  62 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Exercise 8.6
  6. / <streambuf.h>
  7. / Implementation of stream I/O
  8. / using the standard I/O functions.
  9. ifndef STREAMBUF_H
  10. define STREAMBUF_H
  11.  
  12. / a buffer for streams
  13. lass streambuf
  14.  
  15.    char  alloc;    // buffer was allocated
  16.  
  17. riend filebuf;
  18. rotected:
  19.    char *base;        // beginning of buffer
  20.    char *pptr;        // next free byte
  21.    char *gptr;        // next filled byte
  22.    char *eptr;        // first byte following buffer
  23.  
  24.    // allocate some space for the buffer
  25.    int doallocate();
  26.  
  27. ublic:
  28.    streambuf();
  29.    streambuf(char* p, int l);
  30.    ~streambuf();
  31.  
  32.    // Empty the buffer. Return EOF on error,
  33.    // 0 on success.
  34.    virtual int overflow(int c = EOF);    
  35.  
  36.    // Fill a buffer. Return EOF on error 
  37.    // or end of input, else the next character
  38.    virtual int underflow();    
  39.  
  40.    // get the current character or EOF
  41.    int sgetc();        
  42.  
  43.    // get the next character
  44.    int snextc();
  45.  
  46.    // advance to the next character
  47.    void stossc();
  48.  
  49.    // Return a character to the buffer.
  50.    void sputbackc(char c);
  51.  
  52.    // put a character into the buffer
  53.    int sputc(int c = EOF);
  54.  
  55.    // supply an area for a buffer.
  56.    streambuf *setbuf(char *p, int len, int count =0);
  57.  
  58.    // check the buffer and allocate if necessary
  59.    int allocate();
  60. ;
  61. endif /* STREAMBUF_H */
  62.